package gases.as3.testing
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.display.Loader;
	import flash.display.LoaderInfo;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.net.URLRequest;
	import flash.utils.setTimeout;
	
	import gases.as3.librarys.compnents.events.GListEvent;
	import gases.as3.librarys.compnents.ui.control.GList;
	import gases.as3.librarys.compnents.ui.control.list.ListCell;
	
	public class TestingList extends Sprite
	{
		public function TestingList()
		{
			super();

			var loader:Loader = new Loader();
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
			loader.load(new URLRequest("F:/llk/1.png"));
		}
		
		private function onComplete(e:Event):void
		{
			var content:DisplayObject = LoaderInfo(e.target).content;
			bmd= Bitmap(content).bitmapData;
			
			list = new GList();
			
			this.addChild(list);
			
			dp = new Array();
			dp.push( {label:"Item 1",icon:bmd } );
			dp.push( {label:"Item 2",icon:bmd } );
			dp.push( {label:"Item 3" ,icon:bmd} );
			
			list.dataProvider= dp;
			
//			setTimeout(showNewList,3000);
			list.addEventListener(GListEvent.ITEM_CLICK,itemClick);
		}
		
		
		private function showNewList():void
		{
			dp.push({label:"Item 4" ,icon:bmd});
			list.dataProvider= dp;
		}
		
		
		private function itemClick(e:GListEvent):void
		{
			trace(e.data + "" +e.index);
		}
		private var dp:Array;
		private var list:GList;
		private var bmd:BitmapData;
	}
}